package cz.data.common.database.utils;

import cz.data.common.support.db.DbType;

public class DbQueryUtil {

    public static void requireSupportJdbc(String dbType) {
        boolean supportJdbc = supportJdbc(dbType);
        if (!supportJdbc) {
            throw new UnsupportedOperationException("不支持Jdbc操作的数据源类型:" + dbType);
        }
    }

    public static boolean supportJdbc(String dbType) {
        DbType type = DbType.getDbType(dbType);
        switch (type) {
            case MYSQL:
            case MARIADB:
            case ORACLE:
            case ORACLE_12C:
            case SQL_SERVER:
            case SQL_SERVER2008:
            case POSTGRE_SQL:
            case VERTICA:
                return true;
            case ELASTICSEARCH:
            case KAFKA:
            case MONGODB:
                return false;
            default:
                throw new UnsupportedOperationException("未适配数据源类型:" + dbType);
        }
    }
}
